package com.wang.lotterysystem.service.dto.activity;

import com.wang.lotterysystem.controller.enums.ActivityPrizeStatusEnum;
import com.wang.lotterysystem.controller.enums.ActivityPrizeTiersEnum;
import com.wang.lotterysystem.controller.enums.ActivityStatusEnum;
import com.wang.lotterysystem.controller.enums.ActivityUserStatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

/**
 * 活动完整信息,用于存储在redis中
 */
@Data
public class ActivityDetailDTO {

    @Schema(description = "活动id")
    private Long activityId;

    @Schema(description = "活动名称")
    private String activityName;

    @Schema(description = "活动描述")
    private String description;

    @Schema(description = "活动状态")
    private ActivityStatusEnum status;

    @Schema(description = "奖品列表")
    private List<PrizeDTO> prizeDTOList;

    @Schema(description = "人员列表")
    private List<UserDTO> userDTOList;

    /**
     * 校验当前活动的状态是否是初始化
     * @return 返回是否是初始化
     */
    public Boolean valid(){
        return this.status.equals(ActivityStatusEnum.RUNNING);
    }

    // ----- 当外部的类和内部的类重名的时候,优先使用内部类 -----

    @Data
    public static class PrizeDTO{
        @Schema(description = "奖品id")
        private Long prizeId;

        @Schema(description = "奖品名称")
        private String name;

        @Schema(description = "奖品描述")
        private String description;

        @Schema(description = "奖品价值")
        private BigDecimal price;

        @Schema(description = "奖品图片")
        private String imageUrl;

        @Schema(description = "奖品等级")
        private ActivityPrizeTiersEnum tiers;

        @Schema(description = "奖品状态")
        private ActivityPrizeStatusEnum status;

        @Schema(description = "奖品数量")
        private Long prizeAmount;

        public Boolean valid(){
            return this.status.equals(ActivityPrizeStatusEnum.INIT);
        }
    }
    @Data
    public static class UserDTO{
        @Schema(description = "用户id")
        private Long userId;

        @Schema(description = "用户名")
        private String userName;

        @Schema(description = "用户状态")
        private ActivityUserStatusEnum status;

        public Boolean valid(){
            return this.status.equals(ActivityUserStatusEnum.INIT);
        }
    }
}